<!--
 * @Author: your name
 * @Date: 2021-08-12 11:15:25
 * @LastEditTime: 2021-08-12 11:26:12
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\3-html&css\day09\02-块元素居中.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body>div{
            width:400px;
            background-color: cornflowerblue;
        }
        body>div:nth-child(1){
            margin:0 auto;
        }
        body>div:nth-child(2){
            float:left;
            margin-left:50%;
            position:relative;
            left:-200px;
        }
        body>div:nth-child(3){
            float:left;
            margin-left:calc(50%-200px);
        }
        body>div:nth(4){
            clear:both;
        }

        body>div:nth-child(5){
            position:relative;
            left:50%;
            margin-left:-200px;
            /* margin-left:calc(50%-200px); */
        }
        body>div:nth-child(6){
            position:absolute;
            left:50%;

        }
    </style>
</head>
<body>
   
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
  
</body>
</html>